package com.ehl.capture.init;

import com.ehl.capture.db.DbConfig;
import com.ehl.capture.kafka.KafkaConsumer;
import com.ehl.capture.tool.OneJVMLocker;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

public class CloudToOtherMain {
    public static Logger logger = Logger.getLogger(CloudToOtherMain.class);
    public static DbConfig dbConfig = new DbConfig();

    static {
        boolean lockSuccess = OneJVMLocker.lockInstance("_running.lock");
        if (!lockSuccess) {
            System.out.println("Already one instance running; press enter to exit.");
            try {
                System.in.read();
            } catch (Exception e) {

            }
            System.exit(-1);
        } else {
            PropertyConfigurator.configure(System.getProperty("user.dir") + "/conf/log4j.properties");
        }
    }

    public static void main(String[] a){
        initBaseInfo();
        new KafkaConsumer().kafkaInit();
    }

    public static void initBaseInfo(){
        logger.info("初始化基础数据...");
        dbConfig.init();
        logger.info("初始化基础数据完成。");
    }
}